package com.wlr.study.leetcode;

public class LeetCode189 {
    public static void rotate(int[] nums, int k) {
        if (nums.length<2){

        }
        reverse(nums, 0, nums.length - 1);
        reverse(nums, 0, k - 1);
        reverse(nums, k, nums.length - 1);
    }

    private static void reverse(int[] nums, int start, int end) {
        while (start < end) {
            int temp = nums[end];
            nums[end] = nums[start];
            nums[start] = temp;
            start++;
            end--;
        }
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6,7};
        LeetCode189.rotate(arr, 3);
        for (int j : arr) {
            System.out.print(j);
        }
    }
}
